<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;
use app\common\exception\ThrowException;

// 前端接口控制器的命名空间
$api_namespace = 'app\api\controller';
Route::get('think', function () {
    return 'hello,ThinkPHP6!';
});

// Route::domain('*', 'api'); 
// Route::domain('api', 'api');
// 对于不存在的static目录下的资源文件设置404访问
Route::get('static', response()->code(404));
// 如果希望在没有匹配到所有的路由规则后执行一条设定的路由，可以注册一个单独的MISS路由
Route::miss(function() {
    // return '404 Not Found!';
    //ThrowException::run('ReqException' ,2000001, 404);
    ThrowException::req(ThrowException::NOT_FOUND_MSG);
});

Route::post('record/add', $api_namespace . '\Record@add');
Route::get('record/lists', $api_namespace . '\Record@lists');

Route::get('haikang/list', $api_namespace . '\Haikang@list');
Route::get('haikang/status', $api_namespace . '\Haikang@status');
Route::get('haikang/data', $api_namespace . '\Haikang@data'); 
Route::get('haikang/sensor', $api_namespace . '\Haikang@sensor');
Route::get('haikang/minitor', $api_namespace . '\Haikang@minitor');
Route::get('haikang/vedio', $api_namespace . '\Haikang@vedio');

Route::post('cat/add', $api_namespace . '\Cat@add');

// 完整域名、子域名和IP部署的路由和绑定功能
// Route::domain('*', function () use ($api_namespace) {
//     // var_dump($api_namespace); die;
//     // 动态注册域名的路由规则
//     Route::get('add', $api_namespace . '\Record@edit');
// })->crossDomainRule();


